/* ------------------------------------------------------------------------*
 *
 * ------------------------------------------------------------------------*/
#include "com_hal.h"
#include "comtask.h"
#include "osObjects.h"   
#include "cominfo.h"
#include "dataproc.h"
#include "stdio.h"

void CmdProc(void);
void WifiCmd(void);
void Cifsr(void);
void ComStringHandle(void);

/*****************************************************************************//*!
* @brief   	com task init .
*               
* @param   none
*
* @return  none
*
* @ Pass/ Fail criteria: none
*****************************************************************************/

void ComTask(void const *argument) {
    //	uint16_t Cnt;
    
    ComInit(9600, COM_PAR_NONE);

    for(;;) {
        // Insert thread code here...
        osDelay(1000);
        
        if(ComTxStCheck())
            printf("Time Now : %4d - %-2d - %2d  %2d : %2d : %2d \r\n",TimeCur.Year,TimeCur.Mon,TimeCur.Day,TimeCur.Hour,TimeCur.Min,TimeCur.Sec);

    }
}

/*****************************************************************************//*!
* @brief   	String Handle .
*               
* @param   none
*
* @return  none
*
* @ Pass/ Fail criteria: none
*****************************************************************************/

void ComStringHandle(void) {
    switch (ComTxBuff[0]) {
            //case 'A': WifiCmd();break;
        case ':': CmdProc();
            break;
        default: break;
    }

    ComRcvSt = COM_RX_IDLE;
    ComRcvCnt = 0;
}

/*****************************************************************************//*!
* @brief   	Data Handle .
*               
* @param   none
*
* @return  none
*
* @ Pass/ Fail criteria: none
*****************************************************************************/

void ComDataHandle(void) {

}

/*****************************************************************************//*!
* @brief   Command Proc .
*               
* @param   none
*
* @return  none
*
* @ Pass/ Fail criteria: none
*****************************************************************************/

void CmdProc() {
    uint8_t Cnt;

    if (CMD_START != ComTxBuff[0])
        return;

    switch (ComTxBuff[1]) {
        case 'T': Cnt = 0;
            while (ComInfo[COM_INFO_TEST][Cnt]) {
                ComTxBuff[Cnt] = ComInfo[COM_INFO_TEST][Cnt];
                Cnt++;
            }
            ComTxBuff[Cnt] = 0;
            ComStringSend(ComTxBuff);
            break;
        case 'V': Cnt = 0;
            while (ComInfo[COM_INFO_VER][Cnt]) {
                ComTxBuff[Cnt] = ComInfo[COM_INFO_VER][Cnt];
                Cnt++;
            }
            ComTxBuff[Cnt] = 0;
            ComStringSend(ComTxBuff);
            break;
        default: break;
    }
}


